package com.spring.config;

import com.alibaba.druid.pool.DruidDataSource;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class JdbcConfiguration {

   /* @Autowired
    private DbProperties dbProperties;

    @Bean
    public DruidDataSource dataSource(){
        DruidDataSource db = new DruidDataSource();
        db.setUrl(dbProperties.getUrl());
        db.setDriverClassName(dbProperties.getDriverClassName());
        db.setUsername(dbProperties.getUsername());
        db.setPassword(dbProperties.getPassword());
        return db;
    }*/




    @Value("${jdbc.url}")
    String url;
    @Value("${jdbc.driverClassName}")
    String driverClassName;
    @Value("${jdbc.username}")
    String username;
    @Value("${jdbc.password}")
    String password;

    @Bean
    public DruidDataSource dataSource() {
        DruidDataSource dataSource = new DruidDataSource();
        dataSource.setUrl(url);
        dataSource.setDriverClassName(driverClassName);
        dataSource.setUsername(username);
        dataSource.setPassword(password);
        return dataSource;
    }


}
